//
//  NSDictionary+safe.m
//  SnapUpload
//
//  Created by jiangao on 16/3/28.
//  Copyright © 2016年 JellyKit Inc. All rights reserved.
//

#import "NSDictionary+safe.h"

@implementation NSDictionary (safe)

/*
 *  we cann't get this safe method to dictionary because we may get wrong crash place
 */

//+(instancetype)dictionaryWithObjects:(const id  _Nonnull __unsafe_unretained *)objects forKeys:(const id<NSCopying>  _Nonnull __unsafe_unretained *)keys count:(NSUInteger)cnt
//{
//    NSUInteger keyCnt = 0, valueCnt = 0;
//    _Nonnull const id *objPtr = objects;
//    _Nonnull const id *keyPtr = keys;
//
//    for (   ; keyCnt < cnt; keyCnt ++, objPtr++) {
//        if (*objPtr == 0)
//        {
//            break;
//        }
//    }
//
//    for (   ; valueCnt < cnt; valueCnt ++, keyPtr++) {
//        if (*keyPtr == 0)
//        {
//            break;
//        }
//    }
//
//    NSUInteger minCnt = MIN(keyCnt, valueCnt);
//
//    NSArray *vs = [NSArray arrayWithObjects:objects count:minCnt];
//    NSArray *ks = [NSArray arrayWithObjects:keys count:minCnt];
//
//    return [self dictionaryWithObjects:vs forKeys:ks];
//}

+ (id)safeDictionaryWithObject:(id)object forKey:(id <NSCopying>)key
{
    if (object==nil || key==nil) {
        return [self dictionary];
    } else {
        return [self dictionaryWithObject:object forKey:key];
    }
}

@end
